import Ember from 'ember';

export default Ember.Controller.extend({
    statusService: Ember.inject.service("current-status"),
    queryCondition:'',
    mainController: Ember.inject.controller('business.mainpage'),
    addNewProject:false,
    name:'',

    actions:{
      //跳转至编辑页
      toDetailPage(project){
        let id=project.get('id');
        this.get("mainController").switchMainPage('nursingproject-detail',{id:id,editMode:"edit"});
      },
      selectCustomer(customer){
        this.set('customer',customer);
      },
      addProject(){
        this.set('addNewProject',true);
      },
      invitation(){
        this.set('addNewProject',false);
      },
      saveNewProject(){
        var _self=this;
        var curUser = this.get("statusService").getUser();
        var newPro=this.store.createRecord('nursingproject',{});
        newPro.set('name',this.get('name'));
        newPro.set('customer',this.get('customer'));
        newPro.set('createUser',curUser);
        newPro.set('delStatus',1);

        newPro.save().then(function(newPro){
          _self.set('addNewProject',false);
          _self.set('name','');
          _self.get("mainController").switchMainPage('nursingproject-detail',{editMode:"add",id:newPro.get('id')});
        });
      }
    },

});
